# -*- coding: utf-8 -*-
"""
Created by edc on 2020/7/29
"""

from operation.test.yaoFun import *


def run(workspace='http://172.16.2.114:9999/edc/gitforyao.git', cmd="python DL.py "):
    os.environ["TZ"] = 'Asia/Shanghai'
    if hasattr(time, 'tzset'):
        time.tzset()

    login()
    get_sys_status()

    tasks = [{
        "name": "node1",
        "image": "edclol/yao-tensorflow",
        # "cmd": "python /workspace/scripts/tf_cnn_benchmarks/tf_cnn_benchmarks.py \\ --num_gpus=1 \\ --batch_size=32 \\ --model=resnet50 \\ --num_batches=200 \\ --train_dir=/tmp \\ --variable_update=parameter_server",
        "cmd": cmd,
        "cpu_number": "4",
        "memory": "30000",
        "gpu_number": "1",
        "gpu_memory": "15109",
        "is_ps": "0",
        "gpu_model": "k80",
    }]
    # print(json.dumps(tasks))
    job = {
        'name': 'test',
        # 'workspace': 'https://github.com/tensorflow/benchmarks.git',
        'workspace': workspace,
        'cluster': 'default',
        'priority': '25',
        'run_before': '',
        'locality': '0',
        'tasks': json.dumps(tasks),
    }

    msg = submit_job(job)
    if msg['errno'] == 0:
        job_status(msg['job_name'])

    job_list()
    job_stop('test-159471298004725633885138')


if __name__ == '__main__':
    run()
